//chika和蜜柑
import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int k = in.nextInt();
            Data[] arr = new Data[n];
            long mina = 0;
            long maxb = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = new Data();
                arr[i].a = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                arr[i].b = in.nextInt();
            }
            Arrays.sort(arr);
            for (int i = n-1; i >= 0 && k > 0; i--) {
                mina += arr[i].a;
                maxb += arr[i].b;
                k--;
            }
            System.out.println(mina+" "+maxb);
        }
    }
    static class Data implements Comparable<Data>{
        public int a;
        public int b;

        @Override
        public int compareTo(Data o) {
            return b-o.b == 0 ? o.a-a : b-o.b;
        }
    }
}

输入两个正整数a和b，输出这两个正整数的和，差，积，商，模（若a>b则输出a-b，a/b，a%b的值反之输出b-a，b/a，b%a的值，不考虑小数，请使用int类型）
输入描述：
两个正整数
输出描述：
它们的和，差，积，商，模。每个值之间用空格隔开



import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();

        if (a > b)
        {
            print(a, b);
        }
        else
        {
            print(b, a);
        }
    }
    public static void print(int x, int y){
        System.out.print((x+y) + " " + (x-y) + " " + (x*y) + " " + (x/y) + " " + (x%y));
    }
}
//BD4
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            int[][] arr = new int[n][m];
            int k = in.nextInt();
            for (int i = 0; i < k; i++) {
                arr[in.nextInt()-1][in.nextInt()-1] = 1;
            }
            float[][] dp = new float[n+1][m+1];
            
            dp[1][1] = 1;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (i == 1 && j == 1) {
                        continue;
                    }
                    if (i == n && j == m) {
                        dp[i][j] = dp[i][j-1]+ dp[i-1][j];
                        continue;
                    }
                    if (arr[i-1][j-1] == 1) {
                        dp[i][j] = 0;
                        continue;
                    }
                    if (i == n) {
                        dp[i][j] = dp[i][j-1] + (dp[i-1][j] * 0.5f);
                        continue;
                    }
                    if (j == m) {
                        dp[i][j] = (dp[i][j-1] * 0.5f) + dp[i-1][j];
                        continue;
                    }
                    dp[i][j] = (dp[i][j-1] * 0.5f) + (dp[i-1][j] * 0.5f);
                }
            }
            // for (int i = 1; i <= n; i++) {
            //     for (int j = 1; j <= m; j++) {
            //         System.out.print( dp[i][j]+" ");
            //     }
            //     System.out.println();}
            System.out.printf("%.2f\n", dp[n][m]);
        }
    }
}